package com.ruoyi.project.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.ClientErrRecord;
import com.ruoyi.project.system.service.IClientErrRecordService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 前端错误数据Controller
 * 
 * @author david
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/front/client_err_record")
public class ClientErrRecordController extends BaseController
{
    @Autowired
    private IClientErrRecordService clientErrRecordService;

    /**
     * 查询前端错误数据列表
     */
    @PreAuthorize("@ss.hasPermi('front:client_err_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClientErrRecord clientErrRecord)
    {
        startPage();
        List<ClientErrRecord> list = clientErrRecordService.selectClientErrRecordList(clientErrRecord);
        return getDataTable(list);
    }

    /**
     * 导出前端错误数据列表
     */
    @PreAuthorize("@ss.hasPermi('front:client_err_record:export')")
    @Log(title = "前端错误数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClientErrRecord clientErrRecord)
    {
        List<ClientErrRecord> list = clientErrRecordService.selectClientErrRecordList(clientErrRecord);
        ExcelUtil<ClientErrRecord> util = new ExcelUtil<ClientErrRecord>(ClientErrRecord.class);
        util.exportExcel(response, list, "前端错误数据数据");
    }

    /**
     * 获取前端错误数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('front:client_err_record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(clientErrRecordService.selectClientErrRecordById(id));
    }

    /**
     * 新增前端错误数据
     */
    @PreAuthorize("@ss.hasPermi('front:client_err_record:add')")
    @Log(title = "前端错误数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClientErrRecord clientErrRecord)
    {
        return toAjax(clientErrRecordService.insertClientErrRecord(clientErrRecord));
    }

    /**
     * 修改前端错误数据
     */
    @PreAuthorize("@ss.hasPermi('front:client_err_record:edit')")
    @Log(title = "前端错误数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClientErrRecord clientErrRecord)
    {
        return toAjax(clientErrRecordService.updateClientErrRecord(clientErrRecord));
    }

    /**
     * 删除前端错误数据
     */
    @PreAuthorize("@ss.hasPermi('front:client_err_record:remove')")
    @Log(title = "前端错误数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(clientErrRecordService.deleteClientErrRecordByIds(ids));
    }
}
